package io.renren.modules.hotel.controller;

import com.sun.javafx.collections.MappingChange;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.hotel.entity.QuestionEntity;
import io.renren.modules.hotel.service.CommonQuestionService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("hotel/question")
public class CommonQuestionController {
    @Autowired
    CommonQuestionService commonQuestionService;

    @RequestMapping("/list")
    @RequiresPermissions("hotel:question:list")
    public R list(@RequestParam Map<String, Object> params) {
        PageUtils page = commonQuestionService.queryPage(params);
        return R.ok().put("page", page);
    }

    @RequestMapping("/insertorupdate")
    @RequiresPermissions("hotel:question:insertorupdate")
    public R InsertOrUpdate(QuestionEntity entity) {
        commonQuestionService.insertOrupdate(entity);
        return R.ok();
    }

    @RequestMapping("/del/{id}")
    @RequiresPermissions("hotel:question:del")
    public R info(@PathVariable("id") Long id) {
        commonQuestionService.delQuestion(id);
        return R.ok();
    }

}
